#include"ChessBoard.h"
#include"GameActivity.h"
#include <iostream>
#include"QPoint"

void ChessBoard::saveState(){
    _chessBoardState.push_back(&_chessBoard);
}
void ChessBoard::undo(){
    _chessBoard = *_chessBoardState.back();
    _chessBoardState.pop_back();
}

std::vector< std::vector<Chess*> >* ChessBoard::getChessBoardInstance(){
    return &_chessBoard;
}
int ChessBoard::getChessBoardWidth(){
    return _chessBoardWidth;
}
int ChessBoard::getChessBoardLength(){
    return _chessBoardLength;
}

void ChessBoard::setPressedPoint(QPoint p){
    if(GameActivity::isStart){
        point = p;
        isNew = true;
    }
}
Chess* ChessBoard::getChess(QPoint p){
    return _chessBoard[p.x()][p.y()];
}
void ChessBoard::MoveChess(QPoint p1,QPoint p2){
    Chess* chess = _chessBoard[p1.x()][p1.y()];
    _chessBoard[p2.x()][p2.y()] = chess;
    _chessBoard[p1.x()][p1.y()] = NULL;
}
void ChessBoard::cleanChess(QPoint p){
    _chessBoard[p.x()][p.y()] = NULL;
}

QPoint ChessBoard::getPosition(){
    while(!isNew&&!GameActivity::isEnd);
    isNew = false;
    return point;
}
